home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / scope / 176-200 / scopedisk180 / arexxtutorial / rexecute / rexecute.rexx < prev    next >
OS/2 REXX Batch file  |  1995-03-19  |  3KB  |  95 lines

  1. /*---------------------------- Start REXX Source ----------------------------*/
  2.  
  3. /*   ****************************/
  4. /*   *      RExecute.rexx       */
  5. /*   * Execute selector program */
  6. /*   *   using ARexx v1.06      */
  7. /*   *         by               */
  8. /*   *     John Dubler,         */
  9. /*   *       25-NOV-89          */
  10. /*   *         v 1.00           */
  11. /*   ****************************/
  12.  
  13. /*   *      Adapted from Dan Schenck's print spooler.  Thanks, Dan! */
  14.  
  15. if ~show(L,'rexxsupport.library') then
  16.   rc = addlib('rexxsupport.library',0,-30,0)
  17.  
  18. if ~show(L,'rexxarplib.library') then
  19.   rc = addlib('rexxarplib.library',0,-30,0)
  20.  
  21. signal on BREAK_C
  22. true = 1
  23. false = 0
  24. cdir = 'rad:s/Common_Apps'
  25. name = "df0:||||"        
  26.  
  27. do forever
  28.   do while(name = "df0:||||")
  29.     name = getfile(20,50,cdir,,'RExecute - Select Function')
  30.     if name = "" then call end_all()
  31.     call parse_dir
  32.   end
  33.   address command
  34.   if index(cdir,":") = 0 then file2show = pragma('D') || cdir || "/" || name
  35.   else if right(cdir,1) ~= ":" then file2show = cdir || "/" || name
  36.        else file2show = cdir || name
  37.   ADDRESS COMMAND 'execute' file2show
  38.   name = "df0:||||"        
  39. end
  40.  
  41. /*                            parse_dir Procedure                           */
  42. /*                                                                          */
  43. /*  Separate the directory portion of the file name if there is any from    */
  44. /*  the file name itself.  "cdir" will contain the new directory or be left */
  45. /*  untouched if there is no directory.  "name" will be modified to only    */
  46. /*  contain the file name itself or "df0:||||" if there is no file name.    */
  47.  
  48. parse_dir: procedure expose cdir name
  49.   if length(name) = 0 then
  50.     do /*  No name or directory  */
  51.       name = "df0:||||"
  52.       return
  53.     end
  54.   if ~exists(name) then
  55.     do /*  Bad directory/file name  */
  56.       name = "df0:||||"
  57.       return
  58.     end
  59.   i_colon = lastpos(":",name)
  60.   i_slash = lastpos("/",name)
  61.   if left(statef(name),1) = "F" then
  62.     do /*  This a file, not just a directory  */
  63.       if i_slash > 0 then
  64.         do /*  At least one subdirectory has been given  */   
  65.           cdir = substr(name,1,i_slash-1)
  66.           name = substr(name,i_slash+1)
  67.           return
  68.         end
  69.       if i_colon > 0 then
  70.         do /*  A main directory has been given  */
  71.           cdir = substr(name,1,i_colon)
  72.           name = substr(name,i_colon+1)
  73.           return
  74.         end
  75.       return
  76.     end
  77.   if i_slash > 0 then
  78.     do /*  A subdirectory with no file has been given  */
  79.       cdir = name
  80.       name = "df0:||||"
  81.       return
  82.     end
  83.   /*  A main directory or subdirectory only has been given  */
  84.   if i_colon = 0 then cdir = cdir || name
  85.   else cdir = name
  86.   name = "df0:||||"
  87.   return
  88.  
  89. BREAK_C:
  90.   call end_all()
  91. end_all: procedure
  92.   exit
  93.  
  94. /*----------------------------- End REXX Source -----------------------------*/
  95.